package munci.core.words;

import munci.core.Word;
import munci.core.WordImpl;
import munci.core.Dictionary.Name;

public class Operators {

	@Name("+") public static final Word.R2<Integer, Integer, Integer> ADD_INT =
		new WordImpl.R2<Integer, Integer, Integer>() {
			public Integer call(Integer p1, Integer p2) {
				return p1 + p2;
			}};

	@Name("-") public static final Word.R2<Integer, Integer, Integer> SUB_INT =
		new WordImpl.R2<Integer, Integer, Integer>() {
			public Integer call(Integer p1, Integer p2) {
				return p1 - p2;
			}};
			
	@Name("*") public static final Word.R2<Integer, Integer, Integer> MUL_INT =
		new WordImpl.R2<Integer, Integer, Integer>() {
			public Integer call(Integer p1, Integer p2) {
				return p1 * p2;
			}};
			
	@Name("/") public static final Word.R2<Integer, Integer, Integer> DIV_INT =
		new WordImpl.R2<Integer, Integer, Integer>() {
			public Integer call(Integer p1, Integer p2) {
				return p1 / p2;
			}};
			
	@Name("==") public static final Word.R2<Boolean, Object, Object> OBJ_EQUALS =
		new WordImpl.R2<Boolean, Object, Object>() {
			public Boolean call(Object p1, Object p2) {
				return p1 == p2;
			}};
			
	@Name("equals") public static final Word.R2<Boolean, Object, Object> EQUALS =
		new WordImpl.R2<Boolean, Object, Object>() {
			public Boolean call(Object p1, Object p2) {
				return p1 != null && p1.equals(p2);
			}};
					
	@Name("compare") public static final Word.R2<Integer, Number, Number> CMP_NUM =
		new WordImpl.R2<Integer, Number, Number>() {
			public Integer call(Number p1, Number p2) {
				return Double.compare(p1.doubleValue(), p2.doubleValue());
			}};
					
//	.add("+", null, new WordImpl.R2<Tokens, Tokens, Tokens>(IMMEDIATE) {
//		public Tokens call(Tokens p1, Tokens p2) {
//			return new Tokens().add("(").addAll(p1).add(")").add("+").add("(").addAll(p2).add(")");
//		}})
}
